import numpy as np
import matplotlib as mpl

import matplotlib.pyplot as plt
from matplotlib import colors

np.random.seed(1222222)

N = 50
x = np.random.rand(N)
y = np.random.rand(N)
c = np.random.randn(N)

cmap = mpl.colors.ListedColormap(['r', 'g'])

# 颜色取值范围
norm = colors.Normalize(vmin=0, vmax=1)
plt.scatter(x, y, c=c, cmap="viridis", norm=norm, alpha=0.5)
plt.colorbar()
plt.xlabel("tsne1")
plt.ylabel("tsne2")
plt.show()
